import 'package:flutter/material.dart';

class LogoApp extends StatefulWidget {
  @override
  _LogoAppState createState() => _LogoAppState();
}
class _LogoAppState extends State<LogoApp> with SingleTickerProviderStateMixin{
  Animation<double> animation;
  AnimationController controller;
  AnimationStatus animationStatus;
  double animationValue;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    controller = AnimationController(
      vsync: this,
      duration: Duration(seconds: 3),
    );
    animation = Tween<double>(begin: 0.0,end: 300.0).animate(controller)
    ..addListener((){
      setState(() {
        animationValue = animation.value;
      });
    })
    ..addStatusListener((AnimationStatus state){
      setState(() {
        animationStatus = state;
      });
    });
  }
  @override
  void dispose() {
    // TODO: implement dispose
    super.dispose();
    controller.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('动画'),
      ),
      body: Container(
        child: Column(
          children: <Widget>[
            GestureDetector(
              child: Text(
              'Start',
              textDirection: TextDirection.ltr,
              ),
              onTap: (){
                controller.reset();
                controller.forward();
              },
            ),
            Text(
              'State'+animationStatus.toString(),
              textDirection: TextDirection.ltr,
            ),
            Text(
              'Value'+animationValue.toString(),
              textDirection: TextDirection.ltr,
            ),
            Container(
              height: animation.value,
              width: animation.value,
              child: Image.network("http://pic18.nipic.com/20111213/8791344_093424951000_2.jpg"),
            )
          ],
        ),
      ),
    );
  }
}
